/**
 * UTC时间转北京时间
 * @param {string} utc_datetime
 * @return {string}
 */
export default function utc2beijing(utc_datetime) {
  const T_pos = utc_datetime.indexOf("T");
  const Z_pos = utc_datetime.indexOf("Z");
  const year_month_day = utc_datetime.substr(0, T_pos);
  const hour_minute_second = utc_datetime.substr(T_pos + 1, Z_pos - T_pos - 1);
  const new_datetime = `${year_month_day} ${hour_minute_second}`;

  // 处理成为时间戳
  let timestamp = new Date(Date.parse(new_datetime));
  timestamp = timestamp.getTime();
  timestamp /= 1000;
  // 增加8个小时，北京时间比utc时间多八个时区
  timestamp += 8 * 60 * 60;

  // 时间戳转为时间
  const beijing_datetime = new Date(parseInt(timestamp, 10) * 1000)
    .toLocaleString()
    .replace(/\//g, "-");

  return beijing_datetime;
}
